package com.mindai.esper.monitor.biz.epl.config;

import com.mindai.esper.monitor.biz.epl.EsperEplService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class EplApplicationListener implements ApplicationRunner {

	@Autowired
	ApplicationContext context;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		// 需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。
		EsperEplService esperEplService = context.getBean(EsperEplService.class);
		log.info("-------------EplApplicationListener-----加载EPL处理表达式----------------------{}", esperEplService);
		if (esperEplService != null && !esperEplService.isLoad()) {
			esperEplService.runEpl();
		}

	}
}